import App from './App'

// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
import ChooseButton from '@/components/ChooseButton.vue'
import Menu from '@/components/Menus.vue'
import CardItem from '@/components/CardItem.vue'
import Tags from '@/components/Tags.vue'
import ArticleShow from '@/components/ArticleShow.vue'
import ItemTag from '@/components/ItemTag.vue'
import ExperienceCard from '@/components/ExperienceCard.vue'
import ReviewItem from '@/components/ReviewItem.vue'
import CouponsItem from '@/components/CouponsItem.vue'
import OrderItem from '@/components/OrderItem.vue'
import ExperienceItem from '@/components/ExperienceItem.vue'
import CommentsItem from '@/components/CommentsItem.vue'
import CollectionItem from '@/components/CollectionItem.vue'
import SearchTag from '@/components/SearchTag.vue'
import iconview from '@/components/iconview.vue'

// 接口挂载
import api from "./api/index.js";
Vue.prototype.$api = api;

Vue.component('ChooseButton', ChooseButton);
Vue.component('Menu', Menu);
Vue.component('CardItem', CardItem);
Vue.component('Tags', Tags); // tag按钮形
Vue.component('ItemTag', ItemTag); // item的内部标签
Vue.component('ArticleShow', ArticleShow);
Vue.component('ExperienceCard', ExperienceCard);
Vue.component('ReviewItem', ReviewItem);
Vue.component('CouponsItem', CouponsItem);
Vue.component('OrderItem', OrderItem);
Vue.component('ExperienceItem', ExperienceItem);
Vue.component('CommentsItem', CommentsItem); // 评论组件
Vue.component('CollectionItem', CollectionItem); // 收藏组件
Vue.component('SearchTag', SearchTag); // 收藏组件
Vue.component('iconview', iconview); 
Vue.prototype.gettime = (fmt, date) => {
	if (fmt == null) fmt = 'yyyy-MM-dd hh:mm:ss'
	var o = {
		"M+": date.getMonth() + 1, //月份 
		"d+": date.getDate(), //日 
		"h+": date.getHours(), //小时 
		"m+": date.getMinutes(), //分 
		"s+": date.getSeconds(), //秒 
		"q+": Math.floor((date.getMonth() + 3) / 3), //季度 
		"S": date.getMilliseconds() //毫秒 
	};
	if (/(y+)/.test(fmt))
		fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
	for (var k in o)
		if (new RegExp("(" + k + ")").test(fmt))
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k])
				.length)));
	return fmt;
}
Vue.prototype.ustime = (time) => {
	var timestamp = Date.parse(new Date()) / 1000

	let cz = timestamp - time;
	var crtTime = new Date(time * 1000);
	if (cz < 60) {
		return '刚刚'
	} else if (cz < 3600) {
		return parseInt(cz / 60) + '分钟前';
	} else if (cz < 86400) {
		return getApp().gettime('hh:mm', crtTime);
	} else if (cz < 31536000) {
		return getApp().gettime('MM-dd', crtTime);
	} else {
		return getApp().gettime('yyyy-MM-dd hh:mm', crtTime);
	}
}

const app = new Vue({
	...App,
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif
